<?php

require_once 'view/contactView.php';
require_once 'model/InputValidationHandler.php';

class emailController {
	
	public function DoControll(){
	$contactView = new contactView;
	
	if(isset($_POST[contactView::SendComment])) {
		
		if($contactView->CheckEmail()==TRUE) {
			
			$value = InputValidationHandler::getValidMessage($_POST[contactView::Comment]);
			
			if($value) {
				$value = (trim($value));
				$contactView->SendMail();
			}
			else {
				echo "<div id='mailNotSent'>Något gick snett...</div>";
				
			}
			
			
		}

	}
	else {
			$contactView->DoForm();
		}

	}	
	

}